﻿@model SDSystem.Models.ServiceMaintain   
@using Ext.Net.MVC;
@using Ext.Net;
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section Header{
    <script type="text/javascript">
        var cbChange1 = function(e) {
            if (e.checked) {
                Ext.getCmp("extendField").enable();
            } else {
                Ext.getCmp("extendField").disable();
            }
        };
        var cbChange2 = function(e) {
            if (e.checked) {
                Ext.getCmp("limitField").enable();
            } else {
                Ext.getCmp("limitField").disable();
            }
        };
        var comboChange1 = function(e) {
            if (e.value == "Contract") {
                Ext.getCmp("tabContract").enable();
                Ext.getCmp("tabContract").show();
            } else {
                Ext.getCmp("tabContract").disable();
            }
            if (e.value == "Funding") {
                Ext.getCmp("tabFunding").enable();
                Ext.getCmp("tabFunding").show();
            } else {
                Ext.getCmp("tabFunding").disable();
            }

        };
        var cbFunding1 = function(e) {
            if (e.checked) {
                Ext.getCmp("fundingContinuationAmount").enable();
                Ext.getCmp("fundingContinuationDetails").enable();
            } else {
                Ext.getCmp("fundingContinuationAmount").disable();
                Ext.getCmp("fundingContinuationDetails").disable();
            }
        };
        var cbFunding2 = function(e) {
            if (e.checked) {
                Ext.getCmp("fundraisingCompleteDate").enable();
            } else {
                Ext.getCmp("fundraisingCompleteDate").disable();
            }
        };

        function deactiveService() {
            var count1 = @ViewBag.CountOrgService;
            var count2 = @ViewBag.CountPreService;
            var id = @ViewBag.ServiceId;
            var conf1 = confirm("Do you want to mark this Service in-active?");
            if(conf1==true) {
                if (count1 > 0 || count2 > 0) {
                    var conf2 = confirm("This Service is already in use, do you want to make this in-active?");
                    if (conf2 == true) {
                        App.direct.DeactiveServiceHaveCheck(id);
                        alert("Deactive Successfull");
                    } else {
                        alert("No Service is deactive");
                    }
                } else {
                    App.direct.DeactiveServiceHaveCheck(id);
                    alert("Deactive Successfull");
                }
            }else {
                alert("No Service is deactive");
            }

        }
    </script>
    
}

@(Html.X().FormPanel()
            .ID("FormPanel1")
            .MarginSpec("0 0 0 0")
            .TopBar(Html.X().Toolbar().Items(items =>
                                                        {
                                                            items.Add(new ToolbarTextItem {Text = "<h3 style=\"color:green\">Service Details</h3>"});

                                                            items.Add(new ToolbarFill());
                                                        })
                                            .Items(
                                                        Html.X().Button().Text("<b>Deactive</b>").Icon(Icon.StopRed).Margins("0 20 0 0").Listeners(ls => ls.Click.Handler = "deactiveService();window.parent.location.reload();parentAutoLoadControl.close();"),
                                                        Html.X().Button().ID("btnSave").Text("<b>Save</b>").Margins("0 20 0 0").Icon(Icon.ScriptSave).DirectEvents(de =>
                                                        {
                                                            de.Click.Url = Url.Action("EditCommit");
                                                            de.Click.EventMask.ShowMask = true;
                                                            de.Click.FormID = "FormPanel1";
                                                        })
                                                        .Listeners(ls => ls.Click.Handler = "window.parent.location.reload();parentAutoLoadControl.close();"),
                                                        Html.X().Button().Text("<b>Back</b>").Icon(Icon.PageBack).Margins("0 20 0 0")
                                                        .Listeners(ls => ls.Click.Handler = "parentAutoLoadControl.close();")
                                                            
                                            )

                            )
            //.Listeners(ls => ls.ValidityChange.Handler="App.")
            .Items(
                    Html.X().TabPanel()
                    .ID("ServiceTabPanel")
                    .MarginSpec("0 0 0 0")
                    .Items(
                     Html.X().FormPanel()
                     .BodyPadding(10)
                     .ID("Detail1")
                     .Title("Detail1")
                     .Layout(LayoutType.Form)
                     .Items(
                      Html.X().FieldContainer()
                              .Layout(LayoutType.HBox)
                              .Items(
                              Html.X().HiddenFor(m=> m.ServiceId).ID("getServiceId"),
                               Html.X().TextFieldFor(m => m.ServiceName).Flex(1).Margins("0 10 10 5").FieldLabel("Service Name <font color=\"red\">*</font>").LabelWidth(200).MsgTarget(MessageTarget.Side),
                               Html.X().Checkbox().ID("checkServiceActive").Flex(1).Margins("0 10 10 5").FieldLabel("Service Active").LabelWidth(200).Value(ViewBag.ServiceActive)
                                    ),
                      Html.X().FieldContainer()
                              .Layout(LayoutType.HBox)
                              .Items(
                               Html.X().TextAreaFor(m => m.ServiceShortDes).Rows(3).Flex(1).Margins("0 10 10 5").FieldLabel("Service Short Description <font color=\"red\">*</font>").LabelWidth(200).MsgTarget(MessageTarget.Side),
                               Html.X().TextAreaFor(m => m.ServiceFullDes).Rows(3).Flex(1).Margins("0 10 10 5").FieldLabel("Service Full Description").LabelWidth(200)
                                    ),
                      Html.X().FieldContainer()
                              .Layout(LayoutType.HBox)
                              .Items(
                               Html.X().ComboBoxFor(m => m.SubType).ID("subType").Flex(1).Margins("0 10 10 5").FieldLabel("Sub Type").LabelWidth(200)
                               .Items(new ListItem("Funding", "Funding"), new ListItem("Contract", "Contract")).Listeners(
                               ls => ls.Change.Fn="comboChange1"),
                               Html.X().TextFieldFor(m => m.DeptCode).Flex(1).Margins("0 10 10 5").FieldLabel("Dept Code <font color=\"red\">*</font>").LabelWidth(200).MsgTarget(MessageTarget.Side)
                                    ),
                      Html.X().FieldContainer()
                              .Layout(LayoutType.HBox)
                              .Items(
                               Html.X().FieldContainer().Flex(1).Margins("0 10 10 5").Layout(LayoutType.HBox).Items(
                                        Html.X().TextField().ID("ContactLookup").Margins("0 10 10 0").FieldLabel("Lead Contact <font color=\"red\">*</font>").LabelWidth(200).Text(ViewBag.ContactTypes).AllowBlank(false).MsgTarget(MessageTarget.Side),
                                    Html.X().HiddenFor(m => m.ContactId).ID("hIdLookup"),
                                    Html.X().LinkButton().Text("Lookup").Margins("0 155 10 5").Listeners(
                                                li => li.Click.Handler = "showWindow('Lookup','/Contact/List/?text=ContactLookup&id=hIdLookup',true,0.85,0.85);")
                                    ),
                               Html.X().ComboBoxFor(m => m.ServiceType).Flex(1).Margins("0 10 10 5").FieldLabel("Service Type <font color=\"red\">*</font>").LabelWidth(200).Items(
                               ViewBag.ServiceType
                               ).MsgTarget(MessageTarget.Side)
                                    ),
                      Html.X().FieldContainer()
                              .Layout(LayoutType.HBox)
                              .Items(
                               Html.X().TextAreaFor(m => m.ClientDescription).Rows(3).Flex(1).Margins("0 10 10 5").FieldLabel("Client Description").LabelWidth(200),
                               Html.X().TextAreaFor(m => m.ServiceDesDelivery).Rows(3).Flex(1).Margins("0 10 10 5").FieldLabel("Service Description-Delivery").LabelWidth(200)
                                    ),
                      Html.X().FieldContainer()
                              .Layout(LayoutType.HBox)
                              .Items(
                               Html.X().ComboBoxFor(m => m.ServiceAttendance).Flex(1).Margins("0 10 10 5").FieldLabel("Service Attendance").LabelWidth(200),
                               Html.X().TextFieldFor(m => m.ServiceContractCode).Flex(1).Margins("0 10 10 5").FieldLabel("Service Contract Code").LabelWidth(200)
                                    ),
                      Html.X().FieldContainer()
                               .Layout(LayoutType.HBox)
                               .Items(
                                Html.X().FieldContainer().Flex(1).Margins("0 10 10 5").Layout(LayoutType.VBox).Items(
                                Html.X().DateFieldFor(m => m.ServiceStartExpected).ID("startExpected").FieldLabel("Service Start Expected").LabelWidth(200).EmptyText("<dd/MM/yy>")
                                ),
                                Html.X().TextFieldFor(m => m.ServiceContractValue).Flex(1).Margins("0 10 10 5").FieldLabel("Service Contract Value").LabelWidth(200)
                                        ),
                       Html.X().FieldContainer()
                               .Layout(LayoutType.HBox)
                               .Items(
                                Html.X().FieldContainer().Flex(1).Margins("0 10 10 5").Layout(LayoutType.VBox).Items(
                                Html.X().DateFieldFor(m => m.ServiceStartDate).ID("startDate").FieldLabel("Service Start Date").LabelWidth(200).EmptyText("<dd/MM/yyy>")
                                ),
                                Html.X().Checkbox().ID("checkStagePayment").Flex(1).Margins("0 10 10 5").FieldLabel("Contract Staged Payment").LabelWidth(200).Value(ViewBag.ServiceStagePayment)
                                        ),
                        Html.X().FieldContainer()
                               .Layout(LayoutType.HBox)
                               .Items(
                                Html.X().FieldContainer().Flex(1).Margins("0 10 10 5").Layout(LayoutType.VBox).Items(
                                Html.X().DateFieldFor(m => m.ServiceEndDate).ID("endDate").FieldLabel("Service End Date").LabelWidth(200).EmptyText("<dd/MM/yyy>")
                                ),
                                Html.X().ComboBoxFor(m => m.ReferralProcess).Flex(1).Margins("0 10 10 5").FieldLabel("Referral Process/Method").LabelWidth(200)
                                        ),
                       Html.X().FieldContainer()
                               .Layout(LayoutType.HBox)
                               .Items(
                               Html.X().FieldContainer().Flex(1).Margins("0 10 10 5").Layout(LayoutType.VBox).Items(
                                    Html.X().Checkbox().ID("checkServiceExtendable").FieldLabel("Service Extendable").LabelWidth(200).Listeners(
                                    ls => ls.Change.Fn="cbChange1").Checked(ViewBag.ServiceExtendable),
                                    Html.X().FieldContainer().ID("extendField").Margins("0 10 10 5").Layout(LayoutType.HBox).Items
                                        (
                                            Html.X().NumberField().ID("yearEx").MinValue(0).Value(ViewBag.YearEx).Step(1).Margins("0 0 10 200").Width(60),
                                            Html.X().Label().Text("Years").Margins("0 10 10 5"),
                                            Html.X().NumberField().ID("monthEx").MinValue(0).MaxValue(11).Value(ViewBag.MonthEx).Step(1).Margins("0 0 10 5").Width(60),
                                            Html.X().Label().Text("Months").Margins("0 10 10 5")
                                        ).Disabled(!ViewBag.ServiceExtendable)
                                      ),
                                Html.X().FieldContainer().Flex(1).Margins("0 10 10 5").Layout(LayoutType.VBox).Items(
                                    Html.X().Checkbox().ID("checkServiceTimeLimited").FieldLabel("Service Time Limited").LabelWidth(200).Listeners(
                                        ls => ls.Change.Fn = "cbChange2").Checked(ViewBag.ServiceTimeLimited),
                                    Html.X().FieldContainer().ID("limitField").Margins("0 10 10 5").Layout(LayoutType.HBox).Items
                                        (
                                            Html.X().NumberField().ID("yearLi").MinValue(0).Value(ViewBag.YearLi).Step(1).Margins("0 0 10 200").Width(60),
                                            Html.X().Label().Text("Years").Margins("0 10 10 5"),
                                            Html.X().NumberField().ID("monthLi").MinValue(0).MaxValue(11).Value(ViewBag.MonthLi).Step(1).Margins("0 0 10 5").Width(60),
                                            Html.X().Label().Text("Months").Margins("0 10 10 5")
                                        ).Disabled(!ViewBag.ServiceTimeLimited)
                                     ))
                           ),

             Html.X().FormPanel()
                     .Title("Detail2")
                     .BodyPadding(10)
                     .Layout(LayoutType.Form)
                     .Items(
                      Html.X().FieldContainer()
                               .Layout(LayoutType.HBox)
                               .Items(
                                Html.X().MultiCombo().ID("ServiceBenefitsCriterion").FieldLabel("Service Benefits Criterion").LabelWidth(200).Margins("0 10 10 5").Flex(1)
                                        .SelectedItems(ViewBag.selectedServiceRef)
                                        .Items(ViewBag.ServiceBenefitsCriterion),
                                 Html.X().MultiCombo().ID("ServiceDisability").FieldLabel("Service Disability Criterion").LabelWidth(200).Margins("0 10 10 5").Flex(1)
                                        .SelectedItems(ViewBag.selectedServiceRef)    
                                        .Items(ViewBag.ServiceDisability)),
                         Html.X().FieldContainer()
                               .Layout(LayoutType.HBox)
                               .Items(
                                Html.X().MultiCombo().ID("ServiceBarriers").FieldLabel("Service Barriers Criterion").LabelWidth(200).Margins("0 10 10 5").Flex(1)
                                        .SelectedItems(ViewBag.selectedServiceRef)
                                        .Items(ViewBag.ServiceBarriers),
                                 Html.X().MultiCombo().ID("ServicePersonal").FieldLabel("Service Personal Circumstances Criterion").LabelWidth(200).Margins("0 10 10 5").Flex(1)
                                     .SelectedItems(ViewBag.selectedServiceRef)
                                     .Items(ViewBag.ServicePersonal)),
                            Html.X().FieldContainer()
                               .Layout(LayoutType.HBox)
                               .Items(
                                Html.X().MultiCombo().ID("ServiceEthnicity").FieldLabel("Service Ethnicity Criterion").LabelWidth(200).Margins("0 10 10 5").Flex(1)
                                    .SelectedItems(ViewBag.selectedServiceRef)
                                    .Items(ViewBag.ServiceEthnicity),
                                 Html.X().MultiCombo().ID("OtherServiceParticipation").FieldLabel("Other Service Participation Criterion").LabelWidth(200).Margins("0 10 10 5").Flex(1)
                                    .SelectedItems(ViewBag.selectedServiceRef)
                                    .Items(ViewBag.OtherServiceParticipation))

                     ),
             Html.X().FormPanel()
                     .Title("Detail3")
                     .BodyPadding(10)
                     .Layout(LayoutType.Form)
                     .Items(
                      Html.X().FieldContainer()
                               .Layout(LayoutType.HBox)
                               .Items(
                                Html.X().MultiCombo().ID("ClientSupportProcess").FieldLabel("Client Support Process").LabelWidth(200).Margins("0 10 10 5").Flex(1)
                                    .SelectedItems(ViewBag.selectedServiceRef)
                                    .Items(ViewBag.ClientSupportProcess),
                                 Html.X().MultiCombo().ID("ClientOutcome").FieldLabel("Client Outcome").LabelWidth(200).Margins("0 10 10 5").Flex(1)
                                    .SelectedItems(ViewBag.selectedServiceRef)
                                    .Items(ViewBag.ClientOutcome)
                                ),
               Html.X().FieldContainer()
                               .Layout(LayoutType.HBox)
                               .Items(
                                Html.X().MultiCombo().ID("Intervention").FieldLabel("Intervention").LabelWidth(200).Margins("0 10 10 5").Flex(1)
                                    .SelectedItems(ViewBag.selectedServiceRef)
                                    .Items(ViewBag.Intervention),
                                 Html.X().MultiCombo().ID("TargetClient").FieldLabel("Target Client").LabelWidth(200).Margins("0 10 10 5").Flex(1)
                                    .SelectedItems(ViewBag.selectedServiceRef)
                                    .Items(ViewBag.TargetClient)
                                ),
              Html.X().FieldContainer()
                               .Layout(LayoutType.HBox)
                               .Items(
                                Html.X().MultiCombo().ID("ClientJourney").FieldLabel("Client Journey").LabelWidth(200).Margins("0 10 10 5").Flex(1)
                                    .SelectedItems(ViewBag.selectedServiceRef)
                                    .Items(ViewBag.ClientJourney),
                                 Html.X().MultiCombo().ID("Accreditations").FieldLabel("Accreditations").LabelWidth(200).Margins("0 10 10 5").Flex(1)
                                    .SelectedItems(ViewBag.selectedServiceRef)
                                    .Items(ViewBag.Accreditations)
                                ),
               Html.X().FieldContainer()
                               .Layout(LayoutType.HBox)
                               .Items(
                                Html.X().MultiCombo().ID("OtherServices").FieldLabel("Other Services").LabelWidth(200).Margins("0 10 10 5").Flex(1)
                                    .SelectedItems(ViewBag.selectedServiceRef)
                                    .Items(ViewBag.OtherServices),
                                Html.X().MultiCombo().ID("ReferralSources").FieldLabel("Referral Sources").LabelWidth(200).Margins("0 10 10 5").Flex(1)
                                    .SelectedItems(ViewBag.selectedServiceRef)
                                    .Items(ViewBag.ReferralSources)
                                ),
              Html.X().FieldContainer()
                               .Layout(LayoutType.HBox)
                               .Items(
                                Html.X().MultiCombo().ID("SupportCentres").FieldLabel("Support Centres").LabelWidth(200).Margins("0 10 10 5").Flex(1)
                                    .SelectedItems(ViewBag.selectedServiceRef)
                                    .Items(ViewBag.SupportCentres),
                                Html.X().ComboBoxFor(m => m.Programme).Flex(1).Margins("0 10 10 5").FieldLabel("Programme").LabelWidth(200)
                                    .SelectedItems( ViewBag.selectedProgramme)
                                    .Items(ViewBag.Programme))
                                ),
          //Tab Organisation
          Html.X().FormPanel()
                     .ID("tabOrg")
                     .Title("Organisation")
                     .Layout(LayoutType.Form)
                     .Items
                        (
                            Html.X().GridPanel()
                            .ID("DataGridPanelOrganisation")
                            .Frame(true)
                            .Store(Html.X().Store().ID("OrganisationStore")
                                    .Model(Html.X().Model().IDProperty("OrgId")
                                        .Fields(
                                            new ModelField("OrgId"),
                                            new ModelField("OrgName"),
                                            new ModelField("OrgShortDescription"),
                                            new ModelField("RolesName")
                                                )
                                            )
                            .RemoteSort(true)
                            .RemotePaging(true)
                            .PageSize(15)
                            .Proxy(
                            Html.X().AjaxProxy()
                                .Url(Url.Action("BindingStore2"))
                                .Reader(Html.X().JsonReader().Root("data"))
                                )
                            )
                    .ColumnModel(
                            Html.X().Column().Text("Organisation Name").DataIndex("OrgName").Flex(1),
                            Html.X().Column().Text("Description").DataIndex("OrgShortDescription").Flex(2),
                            Html.X().Column().Text("Role Name").DataIndex("RolesName").Flex(1),
                            Html.X().CommandColumn().Width(50).Commands(
                                Html.X().GridCommand().CommandName("Edit Role").Text("<i style=\"color:blue;text-decoration:underline\">Edit Role</i>").ToolTip(tt => tt.Text = "Add/Remove Role"))
                                        .Listeners(ls => ls.Command.Handler = "showWindow('List Organisation Role','/Service/EditOrgRole/'+record.data.OrgId,true,0.85,0.85);").Flex(1)
                        )
                    ).BottomBar(Html.X().PagingToolbar()),
          //Tab Premises
           Html.X().FormPanel()
                     .ID("tabPremises")
                     .Title("Premises")
                     .Layout(LayoutType.Form)
                     .Items(
                        Html.X().GridPanel().ID("PremiseDataGridPanel")
                                .Frame(true)
                                .Store(Html.X().Store().ID("PremisesListStore")
                                        .Model(Html.X().Model().IDProperty("PremiseId")
                                        .Fields(
                                            new ModelField("PremiseId",ModelFieldType.Int),
                                            new ModelField("PremiseName"),
                                            new ModelField("AddressLine1"),
                                            new ModelField("PhoneNumber"),
                                            new ModelField("ProjectCode")
                                        )
                                    )
                                    .RemoteSort(true)
                                    .RemotePaging(true)
                                    .RemoteFilter(true)
                                    .PageSize(15)
                                    .Proxy(
                                                Html.X().AjaxProxy()
                                                    .Url(Url.Action("BindingStore1"))
                                                    .Reader(Html.X().JsonReader().Root("data"))
                                            )


                                )
                                .ColumnModel(
                                            Html.X().Column().Text("ID").DataIndex("PremiseId").Flex(1),
                                            Html.X().TemplateColumn().Text("Premise Name").TemplateString("<a href='javascript:void(0)' onclick='showWindow(\"Edit Premise\",\"/Premises/Edit/\" + {PremiseId}, true, 0.85, 0.85);'>{PremiseName}</a>").Flex(2),
                                            Html.X().Column().Text("Address Line").DataIndex("AddressLine1").Flex(2),
                                            Html.X().Column().Text("Phone Number").DataIndex("PhoneNumber").Flex(1),
                                            Html.X().Column().Text("Project Code").DataIndex("ProjectCode").Flex(1),
                                            Html.X().CommandColumn().Width(50).Commands(
                                                    Html.X().GridCommand().CommandName("Delete").Icon(Icon.Delete).ToolTip(tt => tt.Text = "Delete"))
                                                            .Listeners(ls => ls.Command.Handler = "#{DirectMethods}.DeletePremises(record.data.PremiseId);").Flex(1)
                                            

                                ).BottomBar( Html.X().Toolbar().Items(items =>
                                                                          {
                                                                              items.Add(new ToolbarFill());

                                                                              items.Add(new Button
                                                                              {
                                                                                  Text = "<b>Associate new Premise</b>",
                                                                                  Margins = "0 20 0 0",
                                                                                  Icon = Icon.Accept,
                                                                                  OnClientClick = "showWindow('List Premises','/Service/ListPremises',true,0.85,0.85);"

                                                                              });
                                                                          }))
                                ),
          Html.X().FormPanel()
                     .Disabled(true)
                     .ID("tabContract")
                     .Title("Contract")
                     .Layout(LayoutType.Form)
                     .BodyPadding(10)
                     .Hidden(false)
                     .Items(
                      Html.X().FieldContainer()
                              .Layout(LayoutType.HBox)
                              .Items(
                              Html.X().FieldContainer()
                                       .Layout(LayoutType.VBox)
                                       .Flex(1)
                                       .Items(
                                        Html.X().MultiComboFor(m => m.ContractOutcome).FieldLabel("Contract Outcome").LabelWidth(200).Margins("0 10 10 5")
                                            .Items(
                                             Html.X().ListItem().Text("Referrals Taken"),
                                             Html.X().ListItem().Text("Job Starts"),
                                             Html.X().ListItem().Text("Retentions"),
                                             Html.X().ListItem().Text("Accredited Training"),
                                             Html.X().ListItem().Text("Motivation Improved")

                                            ),
                                         Html.X().ComboBoxFor(m => m.Participation).FieldLabel("Participation").LabelWidth(200).Margins("0 10 10 5")
                                        ),
                               Html.X().FieldContainer()
                                       .Layout(LayoutType.VBox)
                                       .Flex(1)
                                       .Items(
                                        Html.X().MultiComboFor(m => m.ContractObligation).FieldLabel("Contract Obligation").LabelWidth(200).Margins("0 10 10 5")
                                            .Items(
                                             Html.X().ListItem().Text("Phone Weekly"),
                                             Html.X().ListItem().Text("Email Weekly")

                                            )
                                        )
                                )
                     ),

          Html.X().FormPanel()
                     .Disabled(true)
                     .ID("tabFunding")
                     .Title("Funding")
                     .BodyPadding(10)
                     .Layout(LayoutType.Form)
                     .Hidden(false)
                     .Items(
                     //General
                      Html.X().FieldSet().Title("General").Collapsible(false).Layout(LayoutType.Form).Items(
                      Html.X().FieldContainer()
                               .Layout(LayoutType.HBox)
                               .Items(
                                Html.X().ComboBoxFor(m => m.FundingSource).Flex(1).Margins("0 10 10 5").FieldLabel("Funding Source").LabelWidth(200),
                                Html.X().FieldContainer().Flex(1).Margins("0 10 10 5").Layout(LayoutType.VBox).Items(
                                Html.X().TextFieldFor(m => m.FundingNeeds).FieldLabel("Funding Needs").LabelWidth(200)
                                )  
                                        ),
                       Html.X().FieldContainer()
                              .Layout(LayoutType.HBox)
                              .Items(
                               Html.X().FieldContainer().Flex(1).Margins("0 10 10 5").Layout(LayoutType.HBox).Items(
                                        Html.X().TextField().ID("ContactLookup1").Margins("0 10 10 0").FieldLabel("Funding Contact Details <font color=\"red\">*</font>").LabelWidth(200).ReadOnly(true).Text(ViewBag.FundingContact).AllowBlank(false).MsgTarget(MessageTarget.Side),
                                    Html.X().HiddenFor(m => m.FundingContactDetail).ID("hIdLookup1"),
                                    Html.X().LinkButton().Text("Lookup").Margins("0 155 10 5").Listeners(
                                                li => li.Click.Handler = "showWindow('Lookup','/Contact/List/?text=ContactLookup1&id=hIdLookup1',true,0.85,0.85);")
                                    ),
                               Html.X().CheckboxFor(m =>m.FundingContinuationNeeded).Flex(1).Margins("0 10 10 5").FieldLabel("Funding Continuation Needed").LabelWidth(200)
                                       .Listeners(ls => ls.Change.Fn="cbFunding1")
                                    ),
                       Html.X().FieldContainer()
                               .Layout(LayoutType.HBox)
                               .Items(
                                Html.X().FieldContainer().Flex(1).Margins("0 10 10 5").Layout(LayoutType.VBox).Items(
                                         Html.X().TextFieldFor(m=>m.FundingAmount).ID("fundingAmount").FieldLabel("Funding Amount <font color=\"red\">*</font>").LabelWidth(200).AllowBlank(false).MsgTarget(MessageTarget.Side)
                                ),
                                Html.X().FieldContainer().Flex(1).Margins("0 10 10 5").Layout(LayoutType.VBox).Items(
                                         Html.X().TextFieldFor(m =>m.FundingContinuationAmount).ID("fundingContinuationAmount").Margins("0 10 10 5").FieldLabel("Funding Continuation Amount").LabelWidth(200).Disabled(true)
                                        )),
                        Html.X().FieldContainer()
                               .Layout(LayoutType.HBox)
                               .Items(
                                Html.X().FieldContainer().Flex(1).Margins("0 10 10 5").Layout(LayoutType.VBox).Items(
                                         Html.X().DateFieldFor(m => m.FundingStart).FieldLabel("Funding Start").LabelWidth(200).EmptyText("<dd/MM/yy>"),
                                         Html.X().DateFieldFor(m => m.FundingEnd).FieldLabel("Funding End").LabelWidth(200).EmptyText("<dd/MM/yy>")
                                    ),
                                Html.X().TextAreaFor(m => m.FundingContinuationDetails).ID("fundingContinuationDetails").FieldLabel("Funding Continuation Details").Rows(3).LabelWidth(200).Margins("0 10 10 5").Flex(1).Disabled(true)
                                )
                       ),
                      //Fundraising For Service Project
                      Html.X().FieldSet().Title("Fundraising For Service Project").Collapsible(false).Layout(LayoutType.Form).Items(
                      Html.X().FieldContainer()
                               .Layout(LayoutType.HBox)
                               .Items(
                                Html.X().TextAreaFor(m => m.FundraisingForText).FieldLabel("Fundraising For Text").Rows(3).LabelWidth(200).Margins("0 10 10 5").Flex(1),
                                Html.X().FieldContainer().Flex(1).Margins("0 10 10 5").Layout(LayoutType.VBox).Items(
                                         Html.X().TextFieldFor(m => m.FundraisingNeeds).FieldLabel("Fundraising Need").LabelWidth(200),
                                         Html.X().DateFieldFor(m => m.FundraisingRequiredBy).FieldLabel("Fundraising Required By").LabelWidth(200).EmptyText("<dd/MM/yy>")
                                    )
                                
                                ),
                       Html.X().FieldContainer()
                               .Layout(LayoutType.HBox)
                               .Items(
                                Html.X().TextAreaFor(m => m.FundraisingWhy).FieldLabel("Fundraising Why").Rows(3).LabelWidth(200).Margins("0 10 10 5").Flex(1),
                                Html.X().FieldContainer().Flex(1).Margins("0 10 10 5").Layout(LayoutType.VBox).Items(
                                         Html.X().CheckboxFor(m => m.FundraisingComplete).FieldLabel("Fundraising Complete").LabelWidth(200)
                                         .Listeners(ls => ls.Change.Fn="cbFunding2"),
                                         Html.X().DateFieldFor(m =>m.FundraisingCompleteDate).ID("fundraisingCompleteDate").FieldLabel("Fundraising Complete Date").LabelWidth(200).EmptyText("<dd/MM/yy>").Disabled(true)
                                    )         
                                )),
                      
                      
                      //Fundraising Donor
                          Html.X().FieldSet().Title("Fundraising Donor").Collapsible(false).Layout(LayoutType.Form).Items(
                          Html.X().FieldContainer()
                                   .Layout(LayoutType.HBox)
                                   .Items(
                                    Html.X().CheckboxFor(m => m.FundraisingDonorAnonymous).FieldLabel("Fundraising Donor Anonymous").LabelWidth(200).Flex(1).Margins("0 10 10 5"),
                                    Html.X().FieldContainer().Flex(1).Margins("0 10 10 5").Layout(LayoutType.VBox).Items(
                                             Html.X().DateFieldFor(m => m.FundraisingDonationDate).FieldLabel("Fundraising Donation Date").LabelWidth(200).EmptyText("<dd/MM/yy>")
                                        )
                                    ),
                        Html.X().FieldContainer()
                            .Layout(LayoutType.HBox)
                            .Items(
                            Html.X().FieldContainer().Flex(1).Margins("0 10 10 5").Layout(LayoutType.VBox).Items(
                                        Html.X().TextFieldFor(m =>m.FundraisingDonorAmount).FieldLabel("Fundraising Donor Amount").LabelWidth(200)
                                ),
                            Html.X().CheckboxFor(m => m.FundraisingDonationIncremental).FieldLabel("Fundraising Donation Incremental").Flex(1).Margins("0 10 10 5").LabelWidth(200)       
                            ))
                          )
                        )
                    )
          )
                        